{// 引入标签库 }
<tagLib name="html" />
<include file="Public:header" />
<script type="text/javascript" src="__TMPL__Common/js/calendar/calendar.php?lang=zh-cn" ></script>
<load href='__TMPL__Common/js/calendar/calendar.css' />
<load href='__TMPL__Common/js/calendar/calendar.js' />
<load href='__TMPL__Common/js/jquery.weebox.js' />
<php>
	function get_user_diamonds($user_id)
	{
		return M("User")->where("id=".intval($user_id))->getField("diamonds");
	}
	function get_user_coin($user_id)
	{
		return M("User")->where("id=".intval($user_id))->getField("coin");
	}
	function to_user_list($user_id)
	{
		return '<a href="'.U('UserGeneral/index',array('id'=>$user_id)).'">'.$user_id.'</a>';
	}
	function get_promoter_user($child_count,$id)
	{
		if($child_count >0)	{
			return $child_count.'<a href="'.U('BmPromoterUser/index',array('bm_promoter_id'=>$id)).'">明细</a>';
		}else{
			return $child_count;
		}

	}
	function get_promoter_one_name($pid)
	{
		$promoter=M("BmPromoter")->where("user_id=".intval($pid))->find();
		return $child_count.'<a href="'.U('BmPromoterOne/index',array('id'=>$promoter['id'])).'">'.$promoter['name'].'</a>';
	}
	function get_account($user_id){
		return '<a href="javascript:account('.$user_id.')">充值钻石</a>';
	}
	function get_promoter_one_id($pid)
	{
		$promoter=M("BmPromoter")->where("user_id=".intval($pid))->find();

		return $child_count.'<a href="'.U('BmPromoterOne/index',array('id'=>$promoter['id'])).'">'.$promoter['id'].'</a>';
	}

	function get_coins($user_id){
	    $coins=M("User")->where("id=".intval($user_id))->getField("coin");
		$open_game = intval(defined('OPEN_GAME_MODULE') && OPEN_GAME_MODULE);
		$open_diamond = intval(defined('OPEN_DIAMOND_GAME_MODULE') && OPEN_DIAMOND_GAME_MODULE);
		if($open_game && !$open_diamond){
			return "<a href=\"javascript:coins('".$user_id."')\">充值游戏币</a>";
		}
		return "";
	}
</php>
<script>
    function account(user_id)
    {
        $.ajax({
            url: ROOT+"?"+VAR_MODULE+"="+MODULE_NAME+"&"+VAR_ACTION+"=account&id="+user_id,
            data: "ajax=1",
            dataType: "json",
            success: function(msg){
                if(msg.status==0){
                    alert(msg.info);
                }
            },
            error: function(){
                $.weeboxs.open(ROOT+'?'+VAR_MODULE+'='+MODULE_NAME+'&'+VAR_ACTION+'=account&id='+user_id, {contentType:'ajax',showButton:false,title:"充值钻石",width:600,height:260});
            }
        });

    }
    function coins(user_id)
    {
        var url = ROOT + "?" + VAR_MODULE + "=Games&" + VAR_ACTION + "=addCoin&user_id=" + user_id;
        $.ajax({
            url: url,
            data: "ajax=1",
            dataType: "json",
            success: function(msg) {
                if (msg.status == 0) {
                    alert(msg.info);
                }
            },
            error: function() {
                $.weeboxs.open(url, {
                    contentType: 'ajax',
                    showButton: false,
                    title: '游戏币管理',
                    width: 600,
                    height: 260
                });
            }
        });
    }
</script>
<div class="main">
<div class="main_title_list"><div class="list-line-ico"></div>二级单位列表</div>
<div class="search_row">
	<form name="search" action="__APP__" method="get">
		<div>二级单位ID：<input type="text" style="width:60px;" class="textbox" name="id" value="{:trim($_REQUEST['id'])}" /></div>
		<div>二级单位名称：<input type="text" class="textbox" name="name" value="{:trim($_REQUEST['name'])}" /></div>
		<div>一级单位名称：<input type="text" class="textbox" name="parent_name" value="{:trim($_REQUEST['parent_name'])}" /></div>
		<div>上级ID：<input type="text" style="width:60px;" class="textbox" name="p_promoter_id" value="{:trim($_REQUEST['p_promoter_id'])}" /></div>
		<div>手机号：<input type="text" style="width:80px;" class="textbox" name="mobile" value="{:trim($_REQUEST['mobile'])}" /></div>
		<div>绑定会员ID：<input type="text" style="width:60px;" class="textbox" name="binding_user_id" value="{:trim($_REQUEST['binding_user_id'])}" /></div>
		<div>状态：
			<select name="is_effect">
				<option value="-1">全部</option>
				<option value="1">有效</option>
				<option value="0">无效</option>
			</select>
		</div>
		<div>创建时间：
			<span><input type="text" class="textbox" style="width:100px;" name="create_time_1" id="create_time_1" value="{$_REQUEST['create_time_1']}" onfocus="this.blur(); return showCalendar('create_time_1', '%Y-%m-%d', false, false, 'btn_create_time_1');" /><input type="button" class="button" id="btn_create_time_1" value="{%SELECT_TIME}" onclick="return showCalendar('create_time_1', '%Y-%m-%d', false, false, 'btn_create_time_1');" /></span>
			- <span><input type="text" class="textbox" style="width:100px;" name="create_time_2" id="create_time_2" value="{$_REQUEST['create_time_2']}" onfocus="this.blur(); return showCalendar('create_time_2', '%Y-%m-%d', false, false, 'btn_create_time_2');" /><input type="button" class="button" id="btn_create_time_2" value="{%SELECT_TIME}" onclick="return showCalendar('create_time_2', '%Y-%m-%d', false, false, 'btn_create_time_2');" /></span>
			<input type="hidden" value="BmPromoterTwo" name="m" />
			<input type="hidden" value="index" name="a" />
			<input type="submit" class="button" value="{%SEARCH}" />
		</div>

	</form>
</div>
<html:list
	id="dataTable"
	style="dataTable"
	name="data"
	checkbox="true"
	action="true"
	datasource="list"
	show="
	,id:二级单位ID|100px
	,name:二级单位名称
	,pid|get_promoter_one_name:上级一级单位名称
	,pid|get_promoter_one_id:上级ID
	,mobile:手机号
	,user_id|to_user_list:绑定会员ID
	,user_id|get_user_diamonds:钻石数
	,user_id|get_user_coin:游戏币数
	,child_count|get_promoter_user=$data['id']:发展推广会员/人
	,create_time|to_date:{%CREATE_TIME}
	,is_effect|get_is_effect=$data['id']:{%IS_EFFECT}"
	actionlist="edit:{%EDIT},user_id|get_account,user_id|get_coins" />
<div class="page">{$page}</div>
</div>
<include file="Public:footer" />